struct Solution {}

impl Solution {
  pub fn day_of_the_week(day: i32, month: i32, year: i32) -> String {
    let mut days = (year - 1970) * 365;
    if year > 1972 {
      days += (year - 1973) / 4 + 1;
    }
    let month_days = [31, 28, 31, 30, 31, 30, 31 , 31, 30 , 31, 30, 31];
    let week = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
    days += month_days[0..(month - 1) as usize].iter().sum::<i32>();
    if year != 2100 && year % 4 == 0 && month > 2 {
      days += 1;
    }
    days += day;
    week[((days + 3) % 7) as usize].to_string()
  }
}

#[cfg(test)]
mod test {
    use crate::day_of_the_week::Solution;

  #[test]
  fn work() {
    assert_eq!(Solution::day_of_the_week(31, 8, 2019), "Saturday".to_string());
  }
}